# Contributor: Taner Tas <taner76@gmail.com>
# Maintainer: Taner Tas <taner76@gmail.com>
pkgname=polybar
pkgver=3.4.3
pkgrel=0
pkgdesc="A fast and easy-to-use tool for creating status bars."
url="https://polybar.github.io/"
arch="all"
license="MIT"
makedepends="
	alsa-lib-dev
	cairo-dev
	cmake
	curl-dev
	i3wm-dev
	jsoncpp-dev
	libmpdclient-dev
	libnl3-dev
	libxcb-dev
	pulseaudio-dev
	python3
	xcb-proto
	xcb-util-cursor-dev
	xcb-util-image-dev
	xcb-util-renderutil-dev
	xcb-util-wm-dev
	xcb-util-xrm-dev
	"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion:bashcomp:noarch
	$pkgname-zsh-completion:zshcomp:noarch
	"
install="
	$pkgname.post-install
	"
_xppver="c5036690ada6695e187722e66f66eb1178d076ba"
_i3ipcppver="0.7.1"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/jaagr/polybar/archive/$pkgver.tar.gz
	xpp-$_xppver.tar.gz::https://github.com/jaagr/xpp/archive/$_xppver.tar.gz
	https://github.com/jaagr/i3ipcpp/archive/v$_i3ipcppver.tar.gz
	fix-wstringop-truncation.patch
	"
options="!check" # No test suite

prepare() {
	mkdir -p build
	rm -rf lib/xpp
	mv "$srcdir"/xpp-$_xppver lib/xpp
	rm -rf lib/i3ipcpp
	mv "$srcdir"/i3ipcpp-$_i3ipcppver lib/i3ipcpp
	default_prepare
}

build() {
	cd "$builddir"/build
	cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=None ..
	cmake --build .
}

package() {
	cd "$builddir"/build
	cmake --build . --target install -- DESTDIR="$pkgdir"
}

bashcomp() {
	pkgdesc="Bash completion for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel bash-completion"

	mkdir -p "$subpkgdir"/usr/share/
	mv "$pkgdir"/usr/share/bash-completion \
		"$subpkgdir"/usr/share/
}

zshcomp() {
	pkgdesc="Zsh completion for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel zsh"

	mkdir -p "$subpkgdir"/usr/share/
	mv "$pkgdir"/usr/share/zsh \
		"$subpkgdir"/usr/share/
}

sha512sums="20ac34375da4634a7fd596f38e98a245186c94f8fd624d1dfdcd6633a3c8470fcc57946a50a59177e9d34689aeb5f6cde49e95b30ad699239a2aabbf0635d31a  polybar-3.4.3.tar.gz
f4d25a911cc7219ebf35b4b7f63d180a4151f30c8147b38aa1adb2af7ce99b3a4641bbd690f6ccf841d855792715fcae50580b402a910ebc6559cacda733e2b2  xpp-c5036690ada6695e187722e66f66eb1178d076ba.tar.gz
ef9f591bb4436916ad038bcb0c15ea3415d1978ff264fb276108ddac89c98515c464fbf252429f6a76589cb78e1434adba2efefb5a844dadad0e261f3806fb72  v0.7.1.tar.gz
5313c9a20b3f56d878dde0b053c8ca689bbbec077b7c7ba47549dac96393de809e14313e76f68b975f334876a472b14a4d82166c10a64623e753007b26e686ca  fix-wstringop-truncation.patch"
